# coding=UTF-8
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from datetime import datetime
import cPickle as pickle
import email
import md5

def keygen(user):
    data = [settings.SECRET_KEY, user.username, datetime.now().__str__()]
    pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
    return md5.new(pickled).hexdigest()

def send_registration_key(user):
    return email.send_registration_key(user, user.registration.get().get_key())
